﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using IMS_1._0;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace IMS_1._0
{
    public partial class login : Form
    {
        public login()
        {
            InitializeComponent();
        }

        private  void Login_bt_Click(object sender, EventArgs e)
        {
            check();
           
        }

        public void check()
        {
            SqlConnection con = new SqlConnection("Data Source=Rao;Initial Catalog=IMS_TEST;User ID=sa;Password=9845621");
            SqlDataAdapter da = new SqlDataAdapter("select * from users where username='"+txt_Usernm_login.Text+"' and password='"+txt_password_login.Text+"'", con);
            DataTable dt=new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("Incorrect Username or Password","Error");
            }
            else
            {
                char type;
                type = Convert.ToChar(dt.Rows[0]["Type"]);
                if (type == 'A')
                {
                    Main_Admin adminmainpage=new Main_Admin();
                    Variables v=new Variables();
                    v.user_id = Convert.ToString(dt.Rows[0]["user_id"]);


                    adminmainpage.Show();
                    this.Hide();
                }
            }
        }
    }
}
